<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>项目服务集群搭建篇 | 选课系统项目文档</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="https://q4.qlogo.cn/g?b=qq&amp;nk=1906249647&amp;s=640">
    <meta name="description" content="风离 & 苏才华">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.cdd75a34.css" as="style"><link rel="preload" href="/assets/js/app.1463cf64.js" as="script"><link rel="preload" href="/assets/js/3.027404ff.js" as="script"><link rel="preload" href="/assets/js/1.01246aca.js" as="script"><link rel="preload" href="/assets/js/14.c212e7b5.js" as="script"><link rel="prefetch" href="/assets/js/10.f00be53f.js"><link rel="prefetch" href="/assets/js/11.5aad7048.js"><link rel="prefetch" href="/assets/js/12.278d760d.js"><link rel="prefetch" href="/assets/js/13.3ec88902.js"><link rel="prefetch" href="/assets/js/15.16a5da8c.js"><link rel="prefetch" href="/assets/js/4.330d092c.js"><link rel="prefetch" href="/assets/js/5.68480449.js"><link rel="prefetch" href="/assets/js/6.412d3c2f.js"><link rel="prefetch" href="/assets/js/7.cacb4248.js"><link rel="prefetch" href="/assets/js/8.73d07ada.js"><link rel="prefetch" href="/assets/js/9.3cbabfc0.js">
    <link rel="stylesheet" href="/assets/css/0.styles.cdd75a34.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-1aefc0b4><div data-v-1aefc0b4><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-1aefc0b4 data-v-1aefc0b4><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-25ba6db2 data-v-1aefc0b4 data-v-1aefc0b4><h3 class="title" data-v-25ba6db2 data-v-25ba6db2>选课系统项目文档</h3> <p class="description" data-v-25ba6db2 data-v-25ba6db2>风离 &amp; 苏才华</p> <label id="box" class="inputBox" data-v-25ba6db2 data-v-25ba6db2><input type="password" value="" data-v-25ba6db2> <span data-v-25ba6db2>Konck! Knock!</span> <button data-v-25ba6db2>OK</button></label> <div class="footer" data-v-25ba6db2 data-v-25ba6db2><span data-v-25ba6db2><i class="iconfont reco-theme" data-v-25ba6db2></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-25ba6db2>vuePress-theme-reco</a></span> <span data-v-25ba6db2><i class="iconfont reco-copyright" data-v-25ba6db2></i> <a data-v-25ba6db2><span data-v-25ba6db2>风离</span>
            
          <!---->
          2022
        </a></span></div></div> <div class="hide" data-v-1aefc0b4><header class="navbar" data-v-1aefc0b4><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://q4.qlogo.cn/g?b=qq&amp;nk=1906249647&amp;s=640" alt="选课系统项目文档" class="logo"> <span class="site-name">选课系统项目文档</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      项目开源地址及接口文档地址
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/fl1906249647/course-selection-system.git" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-gitee"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://www.apifox.cn/apidoc/shared-42f65f6e-94ab-4a81-88ba-6c4700c21c8e" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  接口文档：密码666666
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-1aefc0b4></div> <aside class="sidebar" data-v-1aefc0b4><div class="personal-info-wrapper" data-v-39576ba9 data-v-1aefc0b4><img src="https://q4.qlogo.cn/g?b=qq&amp;nk=1906249647&amp;s=640" alt="author-avatar" class="personal-img" data-v-39576ba9> <h3 class="name" data-v-39576ba9>
    风离
  </h3> <div class="num" data-v-39576ba9><div data-v-39576ba9><h3 data-v-39576ba9>4</h3> <h6 data-v-39576ba9>Articles</h6></div> <div data-v-39576ba9><h3 data-v-39576ba9>26</h3> <h6 data-v-39576ba9>Tags</h6></div></div> <ul class="social-links" data-v-39576ba9></ul> <hr data-v-39576ba9></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      项目开源地址及接口文档地址
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/fl1906249647/course-selection-system.git" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-gitee"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://www.apifox.cn/apidoc/shared-42f65f6e-94ab-4a81-88ba-6c4700c21c8e" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  接口文档：密码666666
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-25ba6db2 data-v-1aefc0b4><h3 class="title" data-v-25ba6db2 data-v-25ba6db2>项目服务集群搭建篇</h3> <!----> <label id="box" class="inputBox" data-v-25ba6db2 data-v-25ba6db2><input type="password" value="" data-v-25ba6db2> <span data-v-25ba6db2>Konck! Knock!</span> <button data-v-25ba6db2>OK</button></label> <div class="footer" data-v-25ba6db2 data-v-25ba6db2><span data-v-25ba6db2><i class="iconfont reco-theme" data-v-25ba6db2></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-25ba6db2>vuePress-theme-reco</a></span> <span data-v-25ba6db2><i class="iconfont reco-copyright" data-v-25ba6db2></i> <a data-v-25ba6db2><span data-v-25ba6db2>风离</span>
            
          <!---->
          2022
        </a></span></div></div> <div data-v-1aefc0b4><main class="page"><section><div class="page-title"><h1 class="title">项目服务集群搭建篇</h1> <div data-v-f875f3fc><i class="iconfont reco-account" data-v-f875f3fc><span data-v-f875f3fc>风离</span></i> <i class="iconfont reco-date" data-v-f875f3fc><span data-v-f875f3fc>3/26/2022</span></i> <!----> <!----></div></div> <div class="theme-reco-content content__default"><h2 id="搭建mysql集群"><a href="#搭建mysql集群" class="header-anchor">#</a> 搭建MySQL集群</h2> <h3 id="创建mysql配置文件-my-cnf"><a href="#创建mysql配置文件-my-cnf" class="header-anchor">#</a> 创建Mysql配置文件 My.cnf</h3> <blockquote><div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token punctuation">[</span>client<span class="token punctuation">]</span> 

default-character-set<span class="token operator">=</span>utf8 

<span class="token punctuation">[</span>mysql<span class="token punctuation">]</span> 

default-character-set<span class="token operator">=</span>utf8 

<span class="token punctuation">[</span>mysqld<span class="token punctuation">]</span> 

<span class="token assign-left variable">init_connect</span><span class="token operator">=</span><span class="token string">'SET collation_connection = utf8_unicode_ci'</span> 

<span class="token assign-left variable">init_connect</span><span class="token operator">=</span><span class="token string">'SET NAMES utf8'</span> 

character-set-server<span class="token operator">=</span>utf8 

collation-server<span class="token operator">=</span>utf8_unicode_ci 

skip-character-set-client-handshake 

skip-name-resolve


<span class="token assign-left variable">server_id</span><span class="token operator">=</span><span class="token number">1</span> 

log-bin<span class="token operator">=</span>mysql-bin 

read-only<span class="token operator">=</span><span class="token number">0</span> 

binlog-do-db<span class="token operator">=</span>school_manager

binlog-do-db<span class="token operator">=</span>cloud_admin_v1


replicate-ignore-db<span class="token operator">=</span>mysql 

replicate-ignore-db<span class="token operator">=</span>sys 

replicate-ignore-db<span class="token operator">=</span>information_schema 

replicate-ignore-db<span class="token operator">=</span>performance_schema

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br></div></div></blockquote> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B625%E5%88%8640%E7%A7%92.png" alt="image-20220318092540616"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B625%E5%88%8618%E7%A7%92.png" alt="image-20220318092518077"></p> <hr> <h3 id="创建持久化存储卷"><a href="#创建持久化存储卷" class="header-anchor">#</a> 创建持久化存储卷</h3> <p><strong>mysql-pvc-master</strong></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B627%E5%88%8646%E7%A7%92.png" alt="image-20220318092746444"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B628%E5%88%8650%E7%A7%92.png" alt="image-20220318092850780"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B629%E5%88%8607%E7%A7%92.png" alt="image-20220318092907626"></p> <h3 id="创建mysql主-服务"><a href="#创建mysql主-服务" class="header-anchor">#</a> 创建Mysql主 服务</h3> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B629%E5%88%8658%E7%A7%92.png" alt="image-20220318092958128"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B630%E5%88%8649%E7%A7%92.png" alt="image-20220318093049682"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B631%E5%88%8619%E7%A7%92.png" alt="image-20220318093119007"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B631%E5%88%8648%E7%A7%92.png" alt="image-20220318093148658"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B632%E5%88%8606%E7%A7%92.png" alt="image-20220318093206227"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B632%E5%88%8623%E7%A7%92.png" alt="image-20220318093223628"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B632%E5%88%8651%E7%A7%92.png" alt="image-20220318093251855"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B633%E5%88%8629%E7%A7%92.png" alt="image-20220318093329042"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B635%E5%88%8636%E7%A7%92.png" alt="image-20220318093536407"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B636%E5%88%8656%E7%A7%92.png" alt="image-20220318093656239"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B637%E5%88%8619%E7%A7%92.png" alt="image-20220318093719880"></p> <p>创建成功</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B637%E5%88%8649%E7%A7%92.png" alt="image-20220318093748979"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B638%E5%88%8627%E7%A7%92.png" alt="image-20220318093827142"></p> <p>日志</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B638%E5%88%8659%E7%A7%92.png" alt="image-20220318093859894"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B640%E5%88%8612%E7%A7%92.png" alt="image-20220318094011985"></p> <h3 id="创建mysql从服务"><a href="#创建mysql从服务" class="header-anchor">#</a> 创建Mysql从服务</h3> <p>同上创建存储卷</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B645%E5%88%8639%E7%A7%92.png" alt="image-20220318094539105"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B645%E5%88%8652%E7%A7%92.png" alt="image-20220318094552756"></p> <p>同上创建配置文件</p> <blockquote><div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token punctuation">[</span>client<span class="token punctuation">]</span> 

default-character-set<span class="token operator">=</span>utf8 

<span class="token punctuation">[</span>mysql<span class="token punctuation">]</span> 

default-character-set<span class="token operator">=</span>utf8 

<span class="token punctuation">[</span>mysqld<span class="token punctuation">]</span> 

<span class="token assign-left variable">init_connect</span><span class="token operator">=</span><span class="token string">'SET collation_connection = utf8_unicode_ci'</span> 

<span class="token assign-left variable">init_connect</span><span class="token operator">=</span><span class="token string">'SET NAMES utf8'</span> 

character-set-server<span class="token operator">=</span>utf8 

collation-server<span class="token operator">=</span>utf8_unicode_ci 

skip-character-set-client-handshake 

skip-name-resolve 

<span class="token assign-left variable">server_id</span><span class="token operator">=</span><span class="token number">2</span>  <span class="token comment"># 这里填2 </span>

log-bin<span class="token operator">=</span>mysql-bin 

read-only<span class="token operator">=</span><span class="token number">1</span>  <span class="token comment"># 从 只读不写</span>

binlog-do-db<span class="token operator">=</span>school_manager

binlog-do-db<span class="token operator">=</span>cloud_admin_v1

replicate-ignore-db<span class="token operator">=</span>mysql 

replicate-ignore-db<span class="token operator">=</span>sys 

replicate-ignore-db<span class="token operator">=</span>information_schema 

replicate-ignore-db<span class="token operator">=</span>performance_schema
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br></div></div></blockquote> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B649%E5%88%8643%E7%A7%92.png" alt="image-20220318094943720"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B653%E5%88%8657%E7%A7%92.png" alt="image-20220318095357646"></p> <p><code>上述步骤基本同与Mysql主服务 差别在于 my.cnf</code></p> <p>创建成功</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B655%E5%88%8618%E7%A7%92.png" alt="image-20220318095518050"></p> <h3 id="配置主从同步"><a href="#配置主从同步" class="header-anchor">#</a> 配置主从同步</h3> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A509%E6%97%B658%E5%88%8619%E7%A7%92.png" alt="image-20220318095819832"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B600%E5%88%8607%E7%A7%92.png" alt="image-20220318100007758"></p> <h4 id="添加用来同步的用户"><a href="#添加用来同步的用户" class="header-anchor">#</a> 添加用来同步的用户</h4> <p><code>GRANT REPLICATION SLAVE ON *.* to 'backup'@'%' identified by 'rewq4321';</code></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B602%E5%88%8626%E7%A7%92.png" alt="image-20220318100225983"></p> <h4 id="查看-master-状态"><a href="#查看-master-状态" class="header-anchor">#</a> 查看 master 状态</h4> <p><code>show master status;</code></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B603%E5%88%8619%E7%A7%92.png" alt="image-20220318100319590"></p> <p>进入从服务 命令行</p> <h4 id="设置主库连接"><a href="#设置主库连接" class="header-anchor">#</a> 设置主库连接</h4> <blockquote><div class="language-my line-numbers-mode"><pre class="language-text"><code>change master to  master_host='10.233.72.75',master_user='backup',master_password='rewq4321',            master_log_file='mysql-bin.000003',master_log_pos=0,master_port=3306;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></blockquote> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B612%E5%88%8627%E7%A7%92.png" alt="image-20220318101227114"></p> <h4 id="启动从库同步"><a href="#启动从库同步" class="header-anchor">#</a> 启动从库同步</h4> <p><code>start slave;</code></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B613%E5%88%8636%E7%A7%92.png" alt="image-20220318101336000"></p> <h4 id="查看slaver状态"><a href="#查看slaver状态" class="header-anchor">#</a> 查看slaver状态</h4> <p><code>show slave status\G;</code></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B615%E5%88%8615%E7%A7%92.png" alt="image-20220318101515750"></p> <h3 id="至此主从配置完成"><a href="#至此主从配置完成" class="header-anchor">#</a> 至此主从配置完成</h3> <p>总结：</p> <p>1）、主从数据库在自己配置文件中声明需要同步哪个数据库，忽略哪个数据库等信息。</p> <p>并且 server-id 不能一样</p> <p>2）、主库授权某个账号密码来同步自己的数据</p> <p>3）、从库使用这个账号密码连接主库来同步数据</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B640%E5%88%8633%E7%A7%92.png" alt="image-20220318104032943"></p> <h2 id="搭建redis单个服务"><a href="#搭建redis单个服务" class="header-anchor">#</a> 搭建Redis单个服务</h2> <h3 id="创建redis-conf"><a href="#创建redis-conf" class="header-anchor">#</a> 创建Redis.conf</h3> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B648%E5%88%8613%E7%A7%92.png" alt="image-20220318104813566"></p> <h3 id="创建redis-pvc"><a href="#创建redis-pvc" class="header-anchor">#</a> 创建Redis pvc</h3> <h3 id="创建redis服务"><a href="#创建redis服务" class="header-anchor">#</a> 创建Redis服务</h3> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B651%E5%88%8648%E7%A7%92.png" alt="image-20220318105148529"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B653%E5%88%8648%E7%A7%92.png" alt="image-20220318105348813"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B656%E5%88%8602%E7%A7%92.png" alt="image-20220318105602670"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B656%E5%88%8657%E7%A7%92.png" alt="image-20220318105657084"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A510%E6%97%B657%E5%88%8642%E7%A7%92.png" alt="image-20220318105741896"></p> <p>成功</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A511%E6%97%B600%E5%88%8653%E7%A7%92.png" alt="image-20220318110053517"></p> <h2 id="搭建rabbitmq单个服务"><a href="#搭建rabbitmq单个服务" class="header-anchor">#</a> 搭建RabbitMQ单个服务</h2> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A511%E6%97%B606%E5%88%8622%E7%A7%92.png" alt="image-20220318110621965"></p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A511%E6%97%B607%E5%88%8615%E7%A7%92.png" alt="image-20220318110715540"></p> <p>成功</p> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A511%E6%97%B609%E5%88%8619%E7%A7%92.png" alt="image-20220318110919671"></p> <h2 id="搭建nacos-单个服务"><a href="#搭建nacos-单个服务" class="header-anchor">#</a> 搭建Nacos 单个服务</h2> <p><img src="https://img.flya.top/img/2022/03/18%E6%97%A516%E6%97%B652%E5%88%8612%E7%A7%92.png" alt="image-20220318165212604"></p> <blockquote><p>选择版本 1.1.4 不然会出问题 。。。</p></blockquote> <h2 id="搭建zipkin"><a href="#搭建zipkin" class="header-anchor">#</a> 搭建Zipkin</h2> <blockquote><div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">docker</span> run -d -p <span class="token number">9411</span>:9411 openzipkin/zipkin
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></blockquote> <h2 id="搭建魔改后的sentinel控制台-增加-可视化配置持久化功能"><a href="#搭建魔改后的sentinel控制台-增加-可视化配置持久化功能" class="header-anchor">#</a> 搭建魔改后的Sentinel控制台(增加 可视化配置持久化功能)</h2> <blockquote><p>项目地址 <code>https://gitee.com/fl1906249647/sentinel.git</code></p></blockquote> <ul><li><p>导入该项目至你的仓库修改 application.propertie 使得其中</p></li> <li><p><img src="https://img.flya.top/img/2022/03/30%E6%97%A502%E6%97%B629%E5%88%8601%E7%A7%92.png" alt="image-20220330022845854"></p></li> <li><p>新建流水线  使用该仓库</p></li> <li><p>自动运行Jenkinfile 即可</p> <blockquote><p>项目端口为 <code>8858</code></p></blockquote></li></ul> <h2 id="配置镜像仓库-二选一-亦可读者自行搭建私人仓库-这里不做演示"><a href="#配置镜像仓库-二选一-亦可读者自行搭建私人仓库-这里不做演示" class="header-anchor">#</a> 配置镜像仓库 二选一（亦可读者自行搭建私人仓库 这里不做演示）</h2> <h3 id="使用阿里云镜像仓库-推荐"><a href="#使用阿里云镜像仓库-推荐" class="header-anchor">#</a> 使用阿里云镜像仓库（推荐~）</h3> <blockquote><ul><li>开通镜像仓库服务</li> <li><img src="https://img.flya.top/img/2022/03/30%E6%97%A502%E6%97%B633%E5%88%8608%E7%A7%92.png" alt="image-20220330023307804"></li> <li>创建命名空间</li> <li><img src="https://img.flya.top/img/2022/03/30%E6%97%A502%E6%97%B633%E5%88%8640%E7%A7%92.png" alt="image-20220330023337761"></li> <li>操作可详见阿里仓库</li> <li><img src="https://img.flya.top/img/2022/03/30%E6%97%A502%E6%97%B634%E5%88%8623%E7%A7%92.png" alt="image-20220330023421566"></li></ul></blockquote> <p>（下述腾讯镜像仓库同理 <code>记住账号密码即可</code> 并在Kubesphere  DevOps平台流水线设置好凭证 ）</p> <h3 id="使用腾讯云镜像仓库"><a href="#使用腾讯云镜像仓库" class="header-anchor">#</a> 使用腾讯云镜像仓库</h3> <blockquote><div class="language-sh line-numbers-mode"><pre class="language-sh"><code>
<span class="token comment">#登录腾讯云docker registry (登录registry的用户名是您的腾讯云的账号ID，密码是您开通镜像仓库服务时设置的密码)</span>
<span class="token function">sudo</span> <span class="token function">docker</span> login --username<span class="token operator">=</span><span class="token number">100023262499</span>  ccr.ccs.tencentyun.com

<span class="token comment">#从registry拉取镜像 (其中[tag]请根据您的镜像版本信息进行填写。)</span>
<span class="token function">sudo</span> <span class="token function">docker</span> pull ccr.ccs.tencentyun.com/choose-course-system/fengli:<span class="token punctuation">[</span>tag<span class="token punctuation">]</span>

<span class="token comment">#将镜像推送到registry (其中[ImageId]请根据您的实际镜像ID信息进行填写, [tag]请根据您的镜像版本信息进行填写。)</span>
<span class="token function">sudo</span> <span class="token function">docker</span> login --username<span class="token operator">=</span><span class="token number">100023262499</span> ccr.ccs.tencentyun.com

<span class="token function">sudo</span> <span class="token function">docker</span> tag <span class="token punctuation">[</span>ImageId<span class="token punctuation">]</span> ccr.ccs.tencentyun.com/choose-course-system/fengli:<span class="token punctuation">[</span>tag<span class="token punctuation">]</span>

<span class="token function">sudo</span> <span class="token function">docker</span> push ccr.ccs.tencentyun.com/choose-course-system/fengli:<span class="token punctuation">[</span>tag<span class="token punctuation">]</span>


</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div></blockquote> <h3 id="解决拉取失败问题-腾讯云仓库改成公有"><a href="#解决拉取失败问题-腾讯云仓库改成公有" class="header-anchor">#</a> 解决拉取失败问题 腾讯云仓库改成公有</h3> <h2 id="附录"><a href="#附录" class="header-anchor">#</a> 附录</h2> <h3 id="查看pod运行情况"><a href="#查看pod运行情况" class="header-anchor">#</a> 查看Pod运行情况</h3> <p><code>kubectl describe pod fl-student-788fc88594-8tg2w --namespace choose-course-system</code></p> <p>https://github.com/opsnull/kubernetes-troubleshooting-book/blob/master/%E6%8E%92%E9%94%99%E6%8C%87%E5%8D%97-Pod.md</p> <h3 id="按条件删除镜像"><a href="#按条件删除镜像" class="header-anchor">#</a> 按条件删除镜像</h3> <blockquote><p><strong>删除历史版本</strong></p> <p>docker rmi <code>docker images | grep 'registry.cn-hangzhou.aliyuncs.com/choose-course-system/fl-student' | awk '{print $3}'</code></p></blockquote> <blockquote><p><strong>删除空构建</strong></p> <p>docker rmi <code>docker images | grep '&lt;none&gt;' | awk '{print $3}'</code></p></blockquote></div></section> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">3/30/2022, 9:15:30 PM</span></div></footer> <!----> <div class="comments-wrapper"><!----></div> <ul class="side-bar sub-sidebar-wrapper" style="width:12rem;" data-v-cb1513f6><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#搭建mysql集群" class="sidebar-link reco-side-搭建mysql集群" data-v-cb1513f6>搭建MySQL集群</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建mysql配置文件-my-cnf" class="sidebar-link reco-side-创建mysql配置文件-my-cnf" data-v-cb1513f6>创建Mysql配置文件 My.cnf</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建持久化存储卷" class="sidebar-link reco-side-创建持久化存储卷" data-v-cb1513f6>创建持久化存储卷</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建mysql主-服务" class="sidebar-link reco-side-创建mysql主-服务" data-v-cb1513f6>创建Mysql主 服务</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建mysql从服务" class="sidebar-link reco-side-创建mysql从服务" data-v-cb1513f6>创建Mysql从服务</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#配置主从同步" class="sidebar-link reco-side-配置主从同步" data-v-cb1513f6>配置主从同步</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#至此主从配置完成" class="sidebar-link reco-side-至此主从配置完成" data-v-cb1513f6>至此主从配置完成</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#搭建redis单个服务" class="sidebar-link reco-side-搭建redis单个服务" data-v-cb1513f6>搭建Redis单个服务</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建redis-conf" class="sidebar-link reco-side-创建redis-conf" data-v-cb1513f6>创建Redis.conf</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建redis-pvc" class="sidebar-link reco-side-创建redis-pvc" data-v-cb1513f6>创建Redis pvc</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#创建redis服务" class="sidebar-link reco-side-创建redis服务" data-v-cb1513f6>创建Redis服务</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#搭建rabbitmq单个服务" class="sidebar-link reco-side-搭建rabbitmq单个服务" data-v-cb1513f6>搭建RabbitMQ单个服务</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#搭建nacos-单个服务" class="sidebar-link reco-side-搭建nacos-单个服务" data-v-cb1513f6>搭建Nacos 单个服务</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#搭建zipkin" class="sidebar-link reco-side-搭建zipkin" data-v-cb1513f6>搭建Zipkin</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#搭建魔改后的sentinel控制台-增加-可视化配置持久化功能" class="sidebar-link reco-side-搭建魔改后的sentinel控制台-增加-可视化配置持久化功能" data-v-cb1513f6>搭建魔改后的Sentinel控制台(增加 可视化配置持久化功能)</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#配置镜像仓库-二选一-亦可读者自行搭建私人仓库-这里不做演示" class="sidebar-link reco-side-配置镜像仓库-二选一-亦可读者自行搭建私人仓库-这里不做演示" data-v-cb1513f6>配置镜像仓库 二选一（亦可读者自行搭建私人仓库 这里不做演示）</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#使用阿里云镜像仓库-推荐" class="sidebar-link reco-side-使用阿里云镜像仓库-推荐" data-v-cb1513f6>使用阿里云镜像仓库（推荐~）</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#使用腾讯云镜像仓库" class="sidebar-link reco-side-使用腾讯云镜像仓库" data-v-cb1513f6>使用腾讯云镜像仓库</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#解决拉取失败问题-腾讯云仓库改成公有" class="sidebar-link reco-side-解决拉取失败问题-腾讯云仓库改成公有" data-v-cb1513f6>解决拉取失败问题 腾讯云仓库改成公有</a></li><li class="level-2" data-v-cb1513f6><a href="/blogs/readme-3.html#附录" class="sidebar-link reco-side-附录" data-v-cb1513f6>附录</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#查看pod运行情况" class="sidebar-link reco-side-查看pod运行情况" data-v-cb1513f6>查看Pod运行情况</a></li><li class="level-3" data-v-cb1513f6><a href="/blogs/readme-3.html#按条件删除镜像" class="sidebar-link reco-side-按条件删除镜像" data-v-cb1513f6>按条件删除镜像</a></li></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div></div></div>
    <script src="/assets/js/app.1463cf64.js" defer></script><script src="/assets/js/3.027404ff.js" defer></script><script src="/assets/js/1.01246aca.js" defer></script><script src="/assets/js/14.c212e7b5.js" defer></script>
  </body>
</html>
